<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">

    <body>

        <ui:composition template="./adminTemplate.xhtml">

            <ui:define name="title">
                List Banner
            </ui:define>

            <ui:define name="contain">
                <h:form id="form" > 
                    <h2 class="ico_mug">
                        List Banner
                        <p:button value="Add Banner" styleClass="button-add" outcome="addBanner.xhtml"/>
                    </h2>
                    <p:messages autoUpdate="true" showDetail="true" showSummary="true"></p:messages>

                    <p:dataTable var="b" value="#{bannerController.allBanner}" id="table-item"   
                                 paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                                 rowsPerPageTemplate="10,15,20" paginator="true" rows="10">
                        <p:column style="text-align: center">  
                            <f:facet name="header">  
                                ID   
                            </f:facet>  
                            <h:outputText value="#{b.id}" />  
                        </p:column>
                        <p:column  style="text-align: center">  
                            <f:facet name="header">  
                                Image  
                            </f:facet>  
                            <p:graphicImage value="../#{b.image}" width="100" id="img"/> 
                            <p:tooltip for="img">  
                                <p:graphicImage value="../#{b.image}" />  
                            </p:tooltip>   
                        </p:column> 
                        <p:column>  
                            <f:facet name="header">  
                                Title  
                            </f:facet>  
                            <h:outputText value="#{b.title}"/>
                        </p:column> 
                        <p:column>  
                            <f:facet name="header">  
                                Link  
                            </f:facet>  
                            <h:outputText value="#{b.link}" />  
                        </p:column> 
                        <p:column>  
                            <f:facet name="header">  
                                Description
                            </f:facet>  
                            <h:outputText value="#{b.description}" />
                        </p:column>
                        <p:column style="text-align: center;vertical-align: middle">  
                            <f:facet name="header">  
                                Status 
                            </f:facet>  
                            <img src="img/#{b.status}.png" border="0" />
                        </p:column> 

                        <p:column style="text-align: center;vertical-align: middle">  
                            <f:facet name="header">  
                                Action  
                            </f:facet>
                            <p:commandLink ajax="false" action="editBanner">
                                <f:setPropertyActionListener value="#{b}" target="#{bannerBean.banner}"/>
                                <img src="img/edit.png" alt="edit"/>
                            </p:commandLink>  
                            <p:commandLink action="#{bannerController.selectedID(b.id)}" oncomplete="confirmation.show()">
                                <img src="img/delete.png" alt="delete"/>
                            </p:commandLink>

                        </p:column> 
                    </p:dataTable> 
                    <p:confirmDialog id="confirmation" message="Are you sure to delete this Banner?"  
                                     header="Delete Banner" severity="alert" widgetVar="confirmation" > 
                        <p:commandButton value="Yes Sure" update=":form:table-item" oncomplete="confirmation.hide()"  
                                         actionListener="#{bannerController.deleteFeedback}" />  
                        <p:commandButton value="Not Yet" onclick="confirmation.hide()" type="button" />   
                    </p:confirmDialog>  
                </h:form>
            </ui:define>

        </ui:composition>

    </body>
</html>
